<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务，帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件，不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types=1);

namespace app\store\controller\supplier;

use app\store\controller\Controller;
use app\store\model\supplier\OrderGoods as OrderGoodsModel;

/**
 * 供应商订单商品
 * Class OrderGoods
 * @package app\store\controller
 */
class OrderGoods extends Controller
{
    /**
     * 订单商品列表
     * @param int $supplierId
     * @return array
     */
    public function list()
    {
        // 订单列表
        $model = new OrderGoodsModel;
        $list = $model->getList($this->request->param());
        return $this->renderSuccess($list);
    }

    /**
     * 订单商品列表导出
     * @param int $supplierId
     * @return array
     */
    public function goods_export()
    {
        // 订单列表
        $model = new OrderGoodsModel;
        $list = $model->goodsListExport($this->request->param());
        if ($list) {
            $path = parse_url($list, PHP_URL_PATH);
            $filename = basename($path);
            return $this->renderSuccess(array('download_url'=>$list,'download_name'=>$filename));
        }
        return $this->renderError($model->getError() ?: '导出失败');
    }
}
